package com.meshnetics.gb.type.impl.zcl;

import com.meshnetics.gb.type.DataTypeID;

/**
 * WRITE DESCRIPTION HERE
 *
 * @author AKovylin
 */
public class TypeInt extends FixedBytesDataType {
    private static final String ALIAS_PEFIX = "int";
    private static final String ID_TYPE_CLASS = "Signed integer";
    private static final String ID_DATA_TYPE_PREFIX = "Signed ";
    private static final String ID_DATA_TYPE_POSTFIX = "-bit integer";

    public static final TypeInt INT_8 = new TypeInt(1,
            new DataTypeID((byte) 0x28, ID_TYPE_CLASS, ID_DATA_TYPE_PREFIX + 8 + ID_DATA_TYPE_POSTFIX));
    public static final TypeInt INT_16 = new TypeInt(2,
            new DataTypeID((byte) 0x29, ID_TYPE_CLASS, ID_DATA_TYPE_PREFIX + 16 + ID_DATA_TYPE_POSTFIX));
    public static final TypeInt INT_24 = new TypeInt(3,
            new DataTypeID((byte) 0x2a, ID_TYPE_CLASS, ID_DATA_TYPE_PREFIX + 24 + ID_DATA_TYPE_POSTFIX));
    public static final TypeInt INT_32 = new TypeInt(4,
            new DataTypeID((byte) 0x2b, ID_TYPE_CLASS, ID_DATA_TYPE_PREFIX + 32 + ID_DATA_TYPE_POSTFIX));
    public static final TypeInt INT_40 = new TypeInt(5,
            new DataTypeID((byte) 0x2c, ID_TYPE_CLASS, ID_DATA_TYPE_PREFIX + 40 + ID_DATA_TYPE_POSTFIX));
    public static final TypeInt INT_48 = new TypeInt(6,
            new DataTypeID((byte) 0x2d, ID_TYPE_CLASS, ID_DATA_TYPE_PREFIX + 48 + ID_DATA_TYPE_POSTFIX));
    public static final TypeInt INT_56 = new TypeInt(7,
            new DataTypeID((byte) 0x2e, ID_TYPE_CLASS, ID_DATA_TYPE_PREFIX + 56 + ID_DATA_TYPE_POSTFIX));
    public static final TypeInt INT_64 = new TypeInt(8,
            new DataTypeID((byte) 0x2f, ID_TYPE_CLASS, ID_DATA_TYPE_PREFIX + 64 + ID_DATA_TYPE_POSTFIX));

    protected TypeInt(int byteSize, DataTypeID dataTypeId) {
        super(new String[]{ALIAS_PEFIX + byteSize * BITS_IN_BYTE}, dataTypeId, byteSize);
    }

    // no byte array cloning needed
    protected FixedBytesDataValue createValue(byte[] bytes) {
        return new Int(this, bytes);
    }
}
